home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TRISSRC.ZIP / anzeige.c next >
C/C++ Source or Header  |  1996-05-19  |  7KB  |  217 lines

  1. /********************************/
  2. /* DNPCTRIS - Anzeigefunktionen */
  3. /********************************/
  4.  
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <dn.h>
  8. #include "DEFS.H"
  9. #include "VARS.H"
  10.  
  11. /* Funktionsprototypen */
  12. void text_info(SPIELER *sp);
  13. void set_feld_koords(SPIELER *sp);
  14. void zeichne_spielfeld();
  15. void zeige_stein(SPIELER *sp);
  16. int box_art(int x, int y, SPIELER *sp, BOOLEAN feld);
  17. void zeige_kaestchen(SPIELER *sp, int x, int y);
  18.  
  19. extern void spieler_tasten();
  20.  
  21. /* Funktionen */
  22. void text_info(SPIELER *sp)
  23. {
  24.     char txt[80], str[20];
  25.  
  26.     if(anz_spieler == 1)
  27.     {
  28.         put_text(&schrift, schrift.char_w * 3, schrift.char_h, "DN - PCTRIS");
  29.         strcpy(txt, "POINTS: ");
  30.         itoa(sp->punkte, str, 10);
  31.         strcat(txt, str);
  32.         put_text(&schrift, schrift.char_w * 3, schrift.char_h * 3, txt);
  33.         strcpy(txt, "LEVEL: ");
  34.         itoa(sp->level, str, 10);
  35.         strcat(txt, str);
  36.         put_text(&schrift, schrift.char_w * 3, schrift.char_h * 5, txt);
  37.         strcpy(txt, "ROWS: ");
  38.         itoa(sp->reihen, str, 10);
  39.         strcat(txt, str);
  40.         put_text(&schrift, schrift.char_w * 3, schrift.char_h * 7, txt);
  41.  
  42.         if(spieler[0].steuern == spieler_tasten)
  43.         {    
  44.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h , "CONTROL KEYS");
  45.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 3, "ESC - QUIT");
  46.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 5, "LEFT - LEFT");
  47.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 7, "RIGHT - RIGHT");
  48.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 9, "DOWN - ROTATION");
  49.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 11, "RCTRL - DROP");
  50.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 13, "F1 - CHANGE");
  51.         }
  52.         else
  53.         {    
  54.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h , "CONTROL KEYS");
  55.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 3, "ESC - QUIT");
  56.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 5, "LEFT - LEFT");
  57.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 7, "RIGHT - RIGHT");
  58.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 9, "UP - ROTATION");
  59.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 11, "DOWN - DROP");
  60.             put_text(&schrift, feld_start_x + FELD_W * steingroesse + schrift.char_w * 3, schrift.char_h * 13, "F1 - CHANGE");
  61.         }
  62.     }
  63.     else
  64.     {
  65.         put_text(&schrift, screen_width / 2 - schrift.char_w * 3, schrift.char_h, "PCTRIS");
  66.         strcpy(txt, "PTS:");
  67.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 2, txt);
  68.         itoa(spieler[0].punkte, txt, 10);
  69.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 3, txt);
  70.         strcpy(txt, "LVL:");
  71.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 4, txt);
  72.         itoa(spieler[0].level, txt, 10);
  73.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 5, txt);
  74.         strcpy(txt, "ROWS:");
  75.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 6, txt);
  76.         itoa(spieler[0].reihen, txt, 10);
  77.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 7, txt);
  78.  
  79.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 9, "CTRL");
  80.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 10, "A");
  81.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 11, "D");
  82.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 12, "LCT");
  83.         put_text(&schrift, schrift.char_w * 1, schrift.char_h * 13, "S");
  84.  
  85.         strcpy(txt, "PTS:");
  86.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 2, txt);
  87.         itoa(spieler[1].punkte, txt, 10);
  88.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 3, txt);
  89.         strcpy(txt, "LVL:");
  90.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 4, txt);
  91.         itoa(spieler[1].level, txt, 10);
  92.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 5, txt);
  93.         strcpy(txt, "ROWS:");
  94.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 6, txt);
  95.         itoa(spieler[1].reihen, txt, 10);
  96.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 7, txt);
  97.  
  98.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 9, "CTRL");
  99.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 10, "LEFT");
  100.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 11, "RIGHT");
  101.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 12, "RCT");
  102.         put_text(&schrift, screen_width - schrift.char_w * 5, schrift.char_h * 13, "DOWN");
  103.     }
  104. }
  105.  
  106. void set_feld_koords(SPIELER *sp)
  107. {
  108.     if(anz_spieler == 1)
  109.     {
  110.         feld_start_x = FELD_STARTX;
  111.         feld_start_y = FELD_STARTY;
  112.     }
  113.     else if(sp->nr == 0)
  114.     {
  115.         feld_start_x = FELD1_STARTX;
  116.         feld_start_y = FELD1_STARTY;
  117.     }
  118.     else
  119.     {
  120.         feld_start_x = FELD2_STARTX;
  121.         feld_start_y = FELD2_STARTY;
  122.     }
  123.  
  124.     if(gfxmode == 0x13)
  125.         steingroesse = 10;
  126.     else
  127.     {
  128.         steingroesse = 20;
  129.         feld_start_x *= 2;
  130.         feld_start_y *= 2;
  131.     }
  132. }
  133.  
  134. void zeichne_spielfeld()
  135. {
  136.     int x, y, i;
  137.  
  138.     putvollbild(hintergrund);
  139.  
  140.     for(i = 0; i < anz_spieler; i++)
  141.     {
  142.         set_feld_koords(&spieler[i]);
  143.  
  144.         for(x = 0; x < FELD_W; x++)
  145.             for(y = 0; y < FELD_H; y++)
  146.                 zeige_kaestchen(&spieler[i], x, y);
  147.  
  148.         text_info(&spieler[i]);
  149.     }
  150. }
  151.  
  152. void zeige_stein(SPIELER *sp)
  153. {
  154.     int x, y, pixnr, px, py;
  155.  
  156.     set_feld_koords(sp);
  157.  
  158.     for(x = 0; x < 4; x++)
  159.         for(y = 0; y < 4; y++)
  160.             if(sp->fallstein.stein[x][y])
  161.             {
  162.                 pixnr = box_art(x, y, sp, FALSE);
  163.  
  164.                 px = feld_start_x + (x + sp->fallstein.x) * steingroesse;
  165.                 py = feld_start_y + (y + sp->fallstein.y) * steingroesse;
  166.                 put(px, py, &steinpix[sp->fallstein.color][pixnr]);
  167.             }
  168. }
  169.  
  170. int box_art(int x, int y, SPIELER *sp, BOOLEAN feld)
  171. {
  172.     int pixnr, color;
  173.  
  174.     if(feld)
  175.     {
  176.         if(sp->feld[x][y] == 0)
  177.             return(0);
  178.  
  179.         color = sp->feld[x][y];
  180.         pixnr = 0;
  181.         if((y == 0) || (sp->feld[x][y - 1] != color))
  182.             pixnr += 1;
  183.         if((x == FELD_W - 1) || (sp->feld[x + 1][y] != color))
  184.             pixnr += 2;
  185.         if((y == FELD_H - 1) || (sp->feld[x][y + 1] != color))
  186.             pixnr += 4;
  187.         if((x == 0) || (sp->feld[x - 1][y] != color))
  188.             pixnr += 8;
  189.     }
  190.     else
  191.     {
  192.         color = sp->fallstein.color;
  193.         pixnr = 0;
  194.         if((y == 0) || !sp->fallstein.stein[x][y - 1])
  195.             pixnr += 1;
  196.         if((x == 3) || !sp->fallstein.stein[x + 1][y])
  197.             pixnr += 2;
  198.         if((y == 3) || !sp->fallstein.stein[x][y + 1])
  199.             pixnr += 4;
  200.         if((x == 0) || !sp->fallstein.stein[x - 1][y])
  201.             pixnr += 8;
  202.     }
  203.  
  204.     return(pixnr);
  205. }
  206.  
  207. void zeige_kaestchen(SPIELER *sp, int x, int y)
  208. {
  209.     int pixnr, px, py;
  210.  
  211.     pixnr = box_art(x, y, sp, TRUE);
  212.  
  213.     px = feld_start_x + x * steingroesse;
  214.     py = feld_start_y + y * steingroesse;
  215.     put(px, py, &steinpix[sp->feld[x][y]][pixnr]);
  216. }
  217.